package br.edu.univas.jobmanager.utilitarios;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.text.MaskFormatter;

public class Utilitarios {
	
	public static final String DATE_FORMAT = "##/##/#### ##:##";
	 public static void changeTheLookAndFeel(JFrame frame){

		 try {
	         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
	         SwingUtilities.updateComponentTreeUI(frame);
	     } 
		 catch ( Exception exception ) {} 
	 }
	 
	 

	 public static Icon getIcon(String caminho) {
	 	ImageIcon icone= new ImageIcon("images/" + caminho);
	 	return icone;
	 }

	public static MaskFormatter getMaskFormatter(String string) {
		MaskFormatter formatter = new MaskFormatter();
		try {
			formatter.setMask(string);
			formatter.setPlaceholderCharacter('_');
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return formatter;
	}
	public static String converteHora(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		String text = sdf.format(date);
		sdf = new SimpleDateFormat("hh:mm");
		text = text + " as " + sdf.format(date);
		return text;
	}
}
